#!bin/bash
#测试环境一键部署
git reset --hard
git pull
mvn clean package -Dmaven.test.skip=true

curPath=$(readlink -f "$(dirname "$0")")
#删除容器
if [ $(docker ps -aq --filter name=common-dubbo-producer) ]; then
  docker rm -f common-dubbo-producer
fi
#删除镜像
if [[ $(docker images |grep ccf/common-dubbo-producer) ]]; then
  docker rmi ccf/common-dubbo-producer:v1.0
fi
cd ${curPath}/common-dubbo/common-dubbo-producer
docker build  -f Dockerfile_test -t ccf/common-dubbo-producer:v1.0 .
docker run --restart=always   --name common-dubbo-producer -d -p 8117:8117 -p 12344:12344 -e NACOS_NAME_SPACE=test -e NACOS_GROUP=DEFAULT_GROUP  ccf/common-dubbo-producer:v1.0

# 1.启动ccf-source

#删除容器
if [ $(docker ps -aq --filter name=ccf-source) ]; then
  docker rm -f ccf-source
fi
#删除镜像
if [[ $(docker images |grep ccf/ccf-source-platform) ]]; then
  docker rmi ccf/ccf-source-platform:v1.0
fi
cd ${curPath}/ccf-business/ccf-source
docker build -f Dockerfile_test -t ccf/ccf-source-platform:v1.0 .
docker run --restart=always   --name ccf-source -d -p 8112:8112 ccf/ccf-source-platform:v1.0

# end.启动common-gateway

#删除容器
if [ $(docker ps -aq --filter name=common-gateway) ]; then
  docker rm -f common-gateway
fi
#删除镜像
if [[ $(docker images |grep ccf/common-gateway-platform) ]]; then
  docker rmi common/common-gateway-platform:v1.0
fi
cd ${curPath}/common-gateway
docker build -f Dockerfile_test -t ccf/common-gateway-platform:v1.0 .
docker run --restart=always   --name common-gateway -d -p 8110:8110 ccf/common-gateway-platform:v1.0